package com.meitianhui.convenitenbuy.module.mine.adapter;

import android.content.Context;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.meitianhui.convenitenbuy.R;
import com.meitianhui.convenitenbuy.module.mine.model.database.SystemNotifyBean;

import java.util.List;

/**
 * Created by amy on 2017/11/21.
 */

public class SystemNotifyAdapter extends BaseQuickAdapter<SystemNotifyBean, BaseViewHolder> {
    public SystemNotifyAdapter(@Nullable List<SystemNotifyBean> data, Context context) {
        super(R.layout.item_sys_notify, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, SystemNotifyBean item) {
        if (item != null)
            if (item.getContent().contains(",时间:")) {
                helper.setText(R.id.tv_item_sys_notify_detail, item.getContent().substring(0,item.getContent().indexOf(",")));
                helper.setVisible(R.id.tv_item_sys_notify_time,true);
                helper.setText(R.id.tv_item_sys_notify_time,item.getContent().substring(item.getContent().indexOf(":")+1,item.getContent().length()));
            }else {
                helper.setText(R.id.tv_item_sys_notify_detail, item.getContent());
                helper.setVisible(R.id.tv_item_sys_notify_time,false);
            }
    }
}
